﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BusinessObjects.BO_GetObjects;
using BussinessObjects;
using BusinessObjects;
using LibraryO2S;

public partial class controls_admin_Guest : Pages_Base
{
    private DataTable objDT;
    protected void Page_Load(object sender, EventArgs e)
    {
        base.removeHGC(divMessage);
        if (!IsPostBack)
            loadData();
    }
    private void loadData()
    {
        try
        {
            base.OpenConnection();
            objDT = BO_Guest.SelectWithPaged(base.Cur_page, base.Page_size, 1);
            base.bindRepeater(rptData, objDT, divMessage);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally { base.CloseConnection(); }
    }
    protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {
            bool flag = false;
            foreach (RepeaterItem item in rptData.Items)
            {
                CheckBox cboCheck = (CheckBox)item.FindControl("cboCheck");
                if (cboCheck.Checked)
                {
                    HiddenField hdfID = (HiddenField)item.FindControl("hdfID");
                    if (!BO_Guest.Delete(Convert.ToInt32(hdfID.Value)))
                        flag = true;
                }
            }
            if (flag)
                divMessage.InnerHtml = O2S_Message.Error("Lỗi", "Sự cố đường truyền mong quý khách trở lại sau !");
            else
                divMessage.InnerHtml = O2S_Message.Success("Thông Báo", "Xóa thành công .");
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = O2S_Message.Error("Lỗi", "Có lỗi xảy ra:" + ex.Message);
        }
    }
}
